<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	template="/layout/template.xhtml">

	<ui:define name="body">

		<h:form styleClass="edit">
			
      <rich:simpleTogglePanel label="JPQL Console" switchType="ajax">

				<s:decorate template="/layout/display.xhtml">
					<ui:define name="label">Iterations:</ui:define>
					<h:inputText id="iterations" value="#{jpqlConsoleAction.iterations}" />
				</s:decorate>

				<s:decorate template="/layout/display.xhtml">
					<ui:define name="label">First result:</ui:define>
					<h:inputText id="first-result" value="#{jpqlConsoleAction.firstResult}" />
				</s:decorate>

				<s:decorate template="/layout/display.xhtml">
					<ui:define name="label">Max results:</ui:define>
					<h:inputText id="max-results" value="#{jpqlConsoleAction.maxResults}" />
				</s:decorate>

				<s:decorate template="/layout/display.xhtml">
					<ui:define name="label">Print results:</ui:define>
					<h:selectBooleanCheckbox id="print-results" value="#{jpqlConsoleAction.printResults}"></h:selectBooleanCheckbox>
				</s:decorate>

				<s:decorate template="/layout/display.xhtml">
					<ui:define name="label">JPQL:</ui:define>
					<h:inputTextarea value="#{jpqlConsoleAction.jpql}" rows="5" cols="100"	id="jpql" />
				</s:decorate>

				<s:div styleClass="actionButtons" style="clear:both;">
					<h:commandLink action="#{jpqlConsoleAction.executeJPQL}" value="&lt;EXECUTE JPQL/&gt;" />
					<!-- rendered="#{s:hasRole('admin')}" -->
				</s:div>
			
			</rich:simpleTogglePanel>
			
		</h:form>
		
		<rich:panel style="margin-top:15px;">
			<f:facet name="header">Search Results (#{jpqlConsoleAction.jpqlResultCount})</f:facet>
			
			<rich:dataTable 
				id="result-list" 
				var="row"
				value="#{jpqlConsoleAction.jpqlResults}"
				rendered="#{not empty jpqlConsoleAction.jpqlResults}">

				<rich:columns value="#{jpqlColumns}" var="column" index="index" id="column_a#{index}">

					<f:facet name="header">
						<h:outputText value="#{column.header}" />
					</f:facet>

					<!-- e.g. [from Entity e] or [select e.property_1, e.property_n from Entity e] -->
					<h:outputText value="#{row[column.index]}" rendered="#{!jpqlConsoleAction.isSingleSubject}" /> 
					
					<!-- e.g. [select e.property from Entity e] -->
					<h:outputText value="#{row}" rendered="#{jpqlConsoleAction.isSingleSubject}" />
					
				</rich:columns>

			</rich:dataTable>

		</rich:panel>

	</ui:define>
</ui:composition>
